local skill = fk.CreateSkill{
  name = "tea__zhuanfu",
}
---@type ActiveSkillSpec
local zhuanfu = {
  anim_type = "special",
  card_num = 1,
  card_filter = function(self, player, to_select, selected)
    if #selected == 0 and Fk:getCardById(to_select):isCommonTrick() then
      local names = {}
      for _, c in ipairs(Self:getPile("tea__zhuanfu_record")) do
        table.insertIfNeed(names, Fk:getCardById(c).trueName)
      end
      return not table.contains(names, Fk:getCardById(to_select).trueName)
    end
  end,
  target_filter = Util.FalseFunc,
  can_use = function(self, player)
    return true
  end,
  on_use = function(self, room, effect)
    local player = effect.from
    local cards = effect.cards
    player:addToPile("tea__zhuanfu_record", cards, true, self.name, player.id)
    room:setPlayerMark(player, "@tea__tengchao_num", 1)
  end,
}
---@type TrigSkelSpec<TrigFunc>
local zhuanfu_trigger = {
  mute = true,
  can_trigger = function(self, event, target, player, data)
    return player:hasSkill(self)
  end,
  on_cost = Util.TrueFunc,
  on_use = function(self, event, target, player, data)
    local room = player.room
    room:notifySkillInvoked(player, zhuanfu.name, "special")
		player:broadcastSkillInvoke(zhuanfu.name)
    local cids = {}
    for _, id in ipairs(room.draw_pile) do
      if Fk:getCardById(id):isCommonTrick() then
        table.insert(cids, id)
      end
    end
    if #cids > 0 then
      local cid = table.random(cids, 1)
      room:obtainCard(player, cid, false, fk.ReasonPrey)
    end
  end,
}
skill:addEffect("active", zhuanfu)
skill:addEffect(fk.GameStart, zhuanfu_trigger)
return skill